home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_FXUSEIT.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
6KB
|
198 lines
*' $Header: E:/test/sysproc/doc/_fxuseit.prv 1.1 12 Aug 1992 16:55:56 Bill Ramos $
PROCEDURE _fxUseIt
PARAMETERS pc_file, pl_useok, pl_scbatt
*---------------------------------------------------------------------
* NAME
* _fxUseIt - Use the correct DBF or View based on extensions
*
* DESCRIPTION
* The _fxUseit procedure is a high level program that will
* do the following:
* Determine the DBF or view to use based on the <pc_file>
* If there is no DBF open, open the catalog DBF or view.
* Otherwise, if the open DBF or view is not the catalog DBF or view,
* Display the Current view vs catalog DBF or view box
* Use one of the two files
* If _fxUseIt could not open the DBF or view, then <pl_useok>
* is set to .F., otherwise it's .F.
*
* SYNOPSIS
* DO _fxUseIt WITH <pc_file>, <pl_useok>
*
* PARAMETERS
* pc_file = target SCR file
* pl_useok = .T. if DBF or view used ok, else .F. It's value is
* forced to .F. at the start of the procedure
* pl_scbatt = SCB file attached, do not call _CatWhich
*
* EXAMPLE
* *-- Put the correct DBF in view based on the SCR linking CODE
* ok = .F. && Set the open DBF or view flag
* DO _fxUseIt WITH "goods.scr", ok && Try and open the file
* IF .NOT. ok && If the open failed
* ... && Handle the failure here
* ENDIF
*
* LIMITATIONS
* Talk must be off, Fields must be off, Exact must be on
*
* DEPENDENCIES
* Calls: _FileRoot(), _FileType(), _Cat4Dbf, _OpenDbf, _CatWhich
* Called by: _FxEntry
*
* VARIABLES
* lc_scrname = Root name for the current SCR file name
* lc_scrext = Extension for SCR file name, should always be SCR
* ll_isview = If the file related to the SCR name in the catalog
* as a QBE file, then it's set to .T., else .F.
* lc_dbf2use = Name of the DBF or QBE file to use based on the current
* file open, or the user's selection in _Cat4Dbf. If the
* value is blank, there is no matching DBF or QBE in the
* catalog, or the user pressed Escape in the
* "Current view" menu.
* lc_catdbf = Root name for the Name of the DBF or QBE file to use.
* ll_usedby = Set by _CatWhich, if .T., then use the associated
* catalog DBF or QBE file. If .F., then use the
* current DBF or QBE.
* ll_esc = Set by _CatWhich, if .T., then the user pressed the
* Escape key in the "Current view" menu.
* lc_view = Name of VIEW if any, blank if not
* ln_vrecno = Record number in the view if a view is active, else
* the value is not defined
*---------------------------------------------------------------------
PRIVATE lc_scrname, lc_scrext, ll_isview, lc_dbf2use, ;
lc_catdbf, ll_usedby, ll_esc, lc_view
lc_scrname = _FileRoot( pc_file )
lc_scrext = _FileType( pc_file )
ll_isview = .F. && Assume match file is DBF
pl_useok = .F. && Assume the file is not used
lc_view = SET( "VIEW" )
IF .NOT. ISBLANK( lc_view )
ln_vrecno = RECNO()
ENDIF
*-- Get the DBF or QBE for the Design file
lc_dbf2use = "" && Preset the DBF or view to use
DO _Cat4Dbf WITH ( lc_scrname + "." + lc_scrext ), ;
lc_dbf2use, ;
ll_isview, ;
.F.
IF .NOT. ISBLANK( lc_view )
SET VIEW TO &lc_view
IF ln_vrecno > 0
GO ln_vrecno
ENDIF
ENDIF
lc_catdbf = _FileRoot( lc_dbf2use ) && Trim up for alias match
IF .NOT. ISBLANK( lc_dbf2use ) && If a DBF or view matched SCR file
IF ISBLANK( DBF() ) && If no DBF is open
IF ll_isview && If this a QBE match
SET VIEW TO ( lc_dbf2use ) && Open the view
pl_useok = .T. && Set the open flag
ELSE
DO _OpenDbf WITH lc_catdbf, 1, pl_useok
ENDIF && ll_isview
ELSE && DBF already in use, so...
IF .NOT. ll_isview
*-- Look for the DBF file associated with the SCR file
IF ALIAS() <> lc_catdbf
ll_usedbf = .F.
ll_esc = .F.
IF .NOT. pl_scbatt
DO _CatWhich WITH lc_catdbf + ".DBF", ;
ll_usedbf, ;
ll_esc
ELSE
ll_usedbf = .T.
ENDIF
IF .NOT. ll_esc && If the user did not press esc
pl_useok = .T. && Set the open flag
IF ll_usedbf && If the DBF was selected
DO _OpenDbf WITH lc_catdbf, 1, pl_useok
ENDIF
ELSE
pl_useok = .F.
ENDIF
ELSE && Alias and current DBF() match
pl_useok = .T. && Correct DBF already in use
ENDIF
ELSE && Related catalog file is a view
*-- Put the view in use if needed
IF _FileRoot( SET("VIEW") ) <> lc_catdbf
ll_usedbf = .F.
ll_esc = .F.
DO _CatWhich WITH lc_catdbf + "." + _FileType( lc_dbf2use ) , ;
ll_usedbf, ;
ll_esc
IF .NOT. ll_esc && If the user did not press esc
IF ll_usedbf && If the view was selected
SET VIEW TO ( lc_dbf2use )&& Open the view
ENDIF
pl_useok = .T. && Set the use ok flag true
ENDIF
ELSE
pl_useok = .T.
ENDIF
ENDIF && Not a QBE file
ENDIF && DBF is not in use and not a new screen
ELSE && No catalog match
IF .NOT. ISBLANK( ALIAS() )
pl_useok = .T. && Use the current view
ENDIF
ENDIF && There was a catalog match
RETURN
*-- EOP: _fxUseIt WITH pc_file, pl_useok
*'-------------------------------------------------------------------------
*' $Log: E:/test/sysproc/doc/_fxuseit.prv $
*'-------------------------------------------------------------------------